import React from 'react'
import { View } from '@tarojs/components'
import { AtTabs, AtTabsPane } from 'taro-ui'
import {TabListDepartment} from './TabListDepartment'
import {HospitalItems} from '../view/HospitalItems'

class TabsInHospAndDept extends React.Component{

    constructor () {
      super(...arguments)
      this.state={
        current:+this.props.current
      }
    }

    handleClick (value) {
      this.setState({
        current: value
      })
    }
    
    render(){
      const tabList = [{ title: '按医院找' }, { title: '按科室找' }]
      return (
        <AtTabs current={this.state.current} tabList={tabList} onClick={this.handleClick.bind(this)}>
          <AtTabsPane current={this.state.current} index={0} >
            <View style='padding: 10px 10px;background-color: #FAFBFC;text-align: center;' >
              <HospitalItems data={this.props.hospital_data}></HospitalItems>
            </View>
          </AtTabsPane>
          <AtTabsPane current={this.state.current} index={1}>
            <View style='padding: 10px 10px;background-color: #FAFBFC;text-align: center;'>
              <TabListDepartment data={this.props.department_data}></TabListDepartment>
            </View>
          </AtTabsPane>
        </AtTabs>
      )
    }
}

export {TabsInHospAndDept}